<jsp:directive.include file="/jsp/includes/taglibs.jsp" />
<script type="text/javascript">

$().ready(function() {

	$(function() {
		$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : '<c:url value="/tiny_mce/tiny_mce.js" />',

			// General options
			theme : "advanced",
			plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

			// Theme options
			theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Example content CSS (should be your site CSS)
			content_css : "css/content.css",

			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",

			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}
		});
	});
	
	$('#user').autocomplete( {
		source:  function(req, add){  
			$.getJSON('<c:url value="/data/admin/accounts.json"/>', req, function(data) {
				var suggestions = [];  
				//process response  
				data = data.accountList;
				$.each(data, function(i, val){  
					suggestions.push(val.name);  
				});
				add(suggestions);
			});
		},
		minLength: 2
	});



	AnyTime.picker( "displayDate", 
		      { format: "%m/%d/%Y", firstDOW: 1 } );
	AnyTime.picker( "displayTime", 
		      { format: "%H:%i", firstDOW: 1 } );	
});
</script>

<form:form commandName="newsEditCommand">
	<fieldset class="full">
		<legend><spring:message code="admin.news.edit.legend"/></legend>
		<form:hidden path="articleId"/>
		<div class="left_50">
			<form:label path="title"><spring:message code="admin.news.edit.title" /></form:label> 
			<form:input path="title"/><form:errors path="title"/>
			
			<br />
			<br />
	
			<form:label path="byline"><spring:message code="admin.news.edit.byline" /></form:label> 
			<form:input path="byline"/><form:errors path="byline"/>
			
			<br />
			<br />
			
			<form:label path="announcement"><spring:message code="admin.news.edit.announcement" /></form:label> 
			<form:checkbox path="announcement"/>
			<form:label path="replyable"><spring:message code="admin.news.edit.replyable" /></form:label> 
			<form:checkbox path="replyable"/>			
			<br />
			<br />			
		</div>
		<div class="right_50">
			<form:errors path="user"/>
			<form:label path="user"><spring:message code="admin.news.edit.user" /></form:label>
 			<form:input path="user"/>
			<br />
			<br />
	
			<form:label path="displayDate"><spring:message code="admin.news.edit.displayDate" /></form:label> 
			<form:input path="displayDate"/><form:errors path="displayDate"/>
			
			<br />
			<br />

			<form:label path="displayTime"><spring:message code="admin.news.edit.displayTime" /></form:label> 
			<form:input path="displayTime"/>
			<form:errors path="displayTime"/>
			<br />
			<br />

		</div>	
		
		<form:errors path="content"/><br/>
		
		<div>
			<form:textarea path="content" id="contentEditor" cssClass="tinymce" cssStyle="width: 100%" />
		</div>
		
		<br/>
	  	<div>
			<form:label path="tags"><spring:message code="admin.news.edit.tags" /></form:label> 
			<form:input path="tags"/><form:errors path="tags"/>
		</div>
		<div style="clear: both">
			<hr/>
		  	<div class="left">
				<input type="submit" class="submitButton" id="submit" value="<spring:message code="admin.news.edit.submit"/>"/>
			</div>  		
		  	<div class="right" style="padding-top: 10px">
		  		<spring:bind path="articleId">
			  		<c:if test="${ !empty status.value}">
						<form:label path="delete"><spring:message code="admin.news.edit.delete" /></form:label> 
						<form:checkbox path="delete"/>
					</c:if>		
				</spring:bind>
			</div>
		</div>  		
  	</fieldset>
</form:form>
